Adding Actions and Outlets to an Existing Class

To add actions and outlets to an existing class:

  1. Edit the class's header and implementation files outside of Interface Builder.

    To create an action, declare a method that takes a single argument named sender and that returns void or that is coerced to be a action, like this:

    - (IBAction)foo: (id)Sender;

    To create an outlet, declare an instance variable that is of type Id or that has the IBOutlet keyword prefixed to its declaration.

  2. Select the class in the Classes display of the nib file window, choose Classes > Read File, and choose the class's header file.
Tip

You can also drag the header file's icon onto the nib file window.

Warning
If you add the actions and outlets in Interface Builder and then generate new header and implementation files, you'll lose any changes you've made to the files.


© 1999 Apple Computer, Inc.